/**
 * Project Name:jh
 * File Name:IPCamRadarInfoDAOImpl.java
 * Package Name:com.jh.dao.impl
 * Date:下午8:52:45
 * Copyright (c) 2021, LZ All Rights Reserved.
 *
*/

package com.jh.dao.impl;

import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jh.dao.IPCamRadarInfoDAO;
import com.jh.pojo.IPCamRadarInfo;
import com.jh.utils.DBUtils;

/**
 * Description: <br/>
 * Date: 下午8:52:45 <br/>
 * 
 * @author lz E-mail:withitren@outlook.com
 * @version
 * @see
 */
public class IPCamRadarInfoDAOImpl implements IPCamRadarInfoDAO {
    static final Logger logger = LoggerFactory.getLogger(IPCamRadarInfoDAOImpl.class);

    @Override
    public List<IPCamRadarInfo> list(String sql, Object[] arr) throws Exception {
        QueryRunner qr = DBUtils.getQueryRunner();
        logger.debug("--->" + sql);
        return qr.query(sql, new BeanListHandler<IPCamRadarInfo>(IPCamRadarInfo.class), arr);
    }

    @Override
    public IPCamRadarInfo getIpCamRadarInfoBySpName(String sql, IPCamRadarInfo iri) throws Exception {

        QueryRunner qr = DBUtils.getQueryRunner();
        logger.debug("--->" + sql + iri.getSp_name());
        return qr.query(sql, new BeanHandler<IPCamRadarInfo>(IPCamRadarInfo.class), iri.getSp_name());
    }

    @Override
    public IPCamRadarInfo getIpCamRadarInfoByRadarIP(String sql, IPCamRadarInfo iri) throws Exception {

        QueryRunner qr = DBUtils.getQueryRunner();
        logger.debug("--->" + sql + iri.getRadar_ip());
        return qr.query(sql, new BeanHandler<IPCamRadarInfo>(IPCamRadarInfo.class), iri.getRadar_ip());
    }

    @Override
    public IPCamRadarInfo getIpCamRadarInfoByIPCamIP(String sql, IPCamRadarInfo iri) throws Exception {

        QueryRunner qr = DBUtils.getQueryRunner();
        logger.debug("--->" + sql + iri.getIpcam_ip());
        return qr.query(sql, new BeanHandler<IPCamRadarInfo>(IPCamRadarInfo.class), iri.getIpcam_ip());
    }

    @Override
    public IPCamRadarInfo getIpCamRadarInfoBySpID(String sql, IPCamRadarInfo iri) throws Exception {

        QueryRunner qr = DBUtils.getQueryRunner();
        logger.debug("--->" + sql + iri.getSp_id().toString());
        return qr.query(sql, new BeanHandler<IPCamRadarInfo>(IPCamRadarInfo.class), iri.getSp_id());
    }

    /*    public static IPCamRadarInfo getIpCamRadarInfo2(String sql, IPCamRadarInfo iri) throws Exception {
    
        QueryRunner qr = DBUtils.getQueryRunner();
        System.out.println("--->" + sql + iri.getSp_name());
        return qr.query(sql, new BeanHandler<IPCamRadarInfo>(IPCamRadarInfo.class), 1);
    }
    
    public static void main(String[] args) {
        try {
            IPCamRadarInfo iri = new IPCamRadarInfo();
            iri.setSp_name("跑道3");
            String sql = "select * from IPCamRadarInfo where sp_name='跑道2' and sp_mark=? ";
            // IPCamRadarInfo tmp = getIpCamRadarInfoBySpName1(sql, iri);
    
            IPCamRadarInfo tmp = getIpCamRadarInfo2(sql, iri);
            System.out.println(tmp.getSp_name());
        } catch (Exception e) {
            logger.error("--->", e.toString());
            System.out.println("---");
            e.printStackTrace();
        }
    }*/

}
